#ifndef __afx_H_
#define __afx_H_
//#include "TypeDefine.h"
#define false 0
#define true 1
#ifndef __PICC18__

#define LOW_BYTE(x)     ((unsigned char)((x)&0xFF))
#define HIGH_BYTE(x)    ((unsigned char)(((x)>>8)&0xFF))
#define LOW_WORD(x)     ((unsigned short)((x)&0xFFFF))
#define HIGH_WORD(x)    ((unsigned short)(((x)>>16)&0xFFFF))
#define WRITETIMER1(x) ((void)(TMR1H=((x)>>8),TMR1L=((x)&0xFF)))
#endif

#ifdef MCC30
#define __delay_us(x) __delay32((unsigned long)((x)*(FCY/1000000.0)))
#define __delay_ms(x) __delay32((unsigned long)((x)*(FCY/1000.0)))
#define di() (_IPL=7)
#define ei() (_IPL=0)
#endif

#define LOW_NIBBLE(x)	(x&0x0F)
#define HIGH_NIBBLE(x)	(x>>4)

#define MAKE_BYTE(h,l)	((h<<4)+(l&0x0f))
#define MAKE_INT(h,l)	(((unsigned int)h<<8)+l)
#define MAKE_WORD(h,l)	(((unsigned long)h<<16)+l)

#define BCD2CHAR(x)	(10*(x>>4)+(x&0x0f))
#define CHAR2BCD(x)	(((x/10)<<4)|(x%10))
void __delay_20ms(unsigned int x);
unsigned long Long2BCD(unsigned long l);
void Byte2ASCII(unsigned char b, unsigned char *h, unsigned char *l);
unsigned char ASCII2Byte(unsigned char h,unsigned char l);
#endif